package br.eng.megaprojetos.view;

import java.util.Arrays;
import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zul.Textbox;

import br.eng.megaprojetos.control.PersonController;
import br.eng.megaprojetos.model.enums.CivilState;
import br.eng.megaprojetos.model.interfaces.IPerson;

@SuppressWarnings({ "serial" })
public abstract class BasePersonComposer<E extends IPerson, G extends PersonController<E>>
		extends BaseMegaComposer<E, G> {
	
	private List<E> listEntitysIndividuals;
	private List<E> listEntitysLegalEntity;
	
	
	protected String cgc;

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		if(update){
			initPageUpdate();
		} 
	}
	
	private void initPageUpdate(){
//		Radio rdCpf = (Radio) getComponentById(component, "rdCpf");
//		Radio rdCnpj = (Radio) getComponentById(component, "rdCnpj");
		((Textbox) getComponentById(component, "txtIndividuals")).setDisabled(true);
		((Textbox) getComponentById(component, "txtLegalEntity")).setDisabled(true);
	}

	public List<CivilState> getListCivilState() {
		return Arrays.asList(CivilState.values());
	}

	public String getCgc() {
		return cgc;
	}

	public void setCgc(String cgc) {
		this.cgc = cgc;
	}

	public List<E> getListEntitysIndividuals() {
		return listEntitysIndividuals;
	}

	public void setListEntitysIndividuals(List<E> listEntitysIndividuals) {
		this.listEntitysIndividuals = listEntitysIndividuals;
	}

	public List<E> getListEntitysLegalEntity() {
		return listEntitysLegalEntity;
	}

	public void setListEntitysLegalEntity(List<E> listEntitysLegalEntity) {
		this.listEntitysLegalEntity = listEntitysLegalEntity;
	}

	@Override
	protected void clearForm() {
		super.clearForm();
		setCgc("");
	}
	
}
